//
//  RegisterViewModel.swift
//  ManBetX
//
//  Created by Cocoa on 2020/4/10.
//  Copyright © 2020 Fullen. All rights reserved.
//

import UIKit


//注册ViewModel
class RegisterViewModel: BaseViewModel {

    enum CaseType {
        case account //账号
        case password //密码
        case phoneNumber//手机号
        case referralCode//推荐码
        case verificationCode//验证码
    }
    
    var imageTitle: String = ""
    var textFieldString: String = ""
    var placeholder: String = ""
    var errorMessage: String = ""
    var isErrorFlag: Bool = false// 当前VM是否有输入错误 
    var caseType: CaseType = .account
    
    override func create() {
        switch self.entity as? CaseType {
        case .account:
            self.imageTitle = "register_icon_account"
            self.textFieldString = ""
            self.placeholder = "账号由4-11位数字或字母组合"
            self.errorMessage = "账号为4-11位数字或字母组合"
            self.isErrorFlag = false
            self.caseType = .account
            
        case .password:
            self.imageTitle = "register_icon_password"
            self.textFieldString = ""
            self.placeholder = "密码由6-11位数字或字母组合"
            self.errorMessage = "密码为6-16位数字及字母组合"
            self.isErrorFlag = false
            self.caseType = .password
            
        case .phoneNumber:
            self.imageTitle = "register_icon_phoneNumber"
            self.textFieldString = ""
            self.placeholder = "请输入11位数的手机号码"
            self.errorMessage = "请输入11位数的手机号码"
            self.isErrorFlag = false
            self.caseType = .phoneNumber
            
        case .referralCode:
            self.imageTitle = "register_icon_referralCode"
            self.textFieldString = ""
            self.placeholder = "推荐码 非必填"
            self.errorMessage = "请输入正确的推荐码"
            self.isErrorFlag = false
            self.caseType = .referralCode
            
        case .verificationCode:
            self.imageTitle = "register_icon_verificationCode"
            self.textFieldString = ""
            self.placeholder = "请输入验证码"
            self.errorMessage = ""
            self.isErrorFlag = false
            self.caseType = .verificationCode
            
        default:
            self.caseType = .account
            self.textFieldString = ""
            self.imageTitle = ""
            self.placeholder = "填写错误"
            self.errorMessage = "填写错误"
            self.isErrorFlag = true
            
        }
    }
   
    override func cellHeight() -> CGFloat {
        if self.caseType == .verificationCode {
            return 48.0
        }
        return 54.0
    }
}
